/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2021-12-03     GC       the first version
 */
#include "led.h"


struct Led_s
{
    uint8_t LED_R;
    uint8_t LED_B;
    uint8_t LED_G;
};//定义一个RGB结构体

struct Led_s Led;

void RGB_Init(void)
{
    //开启配置引脚
    Led.LED_R = rt_pin_get("PE.1");
    Led.LED_G = rt_pin_get("PE.4");
    Led.LED_B = rt_pin_get("PA.1");
    //配置引脚模式
    rt_pin_mode(Led.LED_R, PIN_MODE_OUTPUT);
    rt_pin_mode(Led.LED_G, PIN_MODE_OUTPUT);
    rt_pin_mode(Led.LED_B, PIN_MODE_OUTPUT);
}
//编写rgb不同颜色驱动，控制电平的高低,低电平点亮
void RGB_Red(rt_bool_t on)
{
    rt_pin_write(Led.LED_B, PIN_HIGH);
    rt_pin_write(Led.LED_G, PIN_HIGH);
    if(on)
    {
        rt_pin_write(Led.LED_R, PIN_LOW);
    }
    else {
        rt_pin_write(Led.LED_R, PIN_HIGH);
    }
}
void RGB_Green(rt_bool_t on)
{
    rt_pin_write(Led.LED_R,PIN_HIGH);
    rt_pin_write(Led.LED_G,PIN_HIGH);
    if(on)
    {
        rt_pin_write(Led.LED_G,PIN_LOW);
    }
    else {
        rt_pin_write(Led.LED_G,PIN_HIGH);
    }
}

void RGB_Blue(rt_bool_t on)
{
    rt_pin_write(Led.LED_R, PIN_HIGH);
    rt_pin_write(Led.LED_G, PIN_HIGH);
    if(on){
        rt_pin_write(Led.LED_B,PIN_LOW);
    }
    else{
        rt_pin_write(Led.LED_B,PIN_HIGH);
    }
    }

